<template>
<view>
<!--hotmall/packageA/login/login.wxml-->
<!-- <text>hotmall/packageA/login/login.wxml</text> -->
<view class="loginModel" :hidden="loginModelHidden">
	<image class="loginImg" src="/static/remao_shop/img/login.png"></image>
	<view class="loginText">我们需要获得您的授权，以继续操作</view>
	<button @getuserinfo="updateUserInfo" class="loginBtn" openType="getUserInfo">
		<image class="loginBtnimg" src="/static/remao_shop/img/weixin.png"></image>微信授权登录
	</button>
</view>
<view class="loginBg" :hidden="loginModelHidden"></view>
</view>
</template>

<script>
import api from "../../../api";
var app = getApp();

export default {
  data() {
    return {
      userId: '',
      name: 'userNickName',
      getList: [],
      loginModelHidden: !0,
      code: 0,
      integList: '0'
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    this.we7login();
    let userId = wx.getStorageSync("userId");
    console.log(userId);
    this.setData({
      userId: userId
    });

    if (e.scene) {
      console.log(e);
      var options = {
        goods_id: e.goods_id,
        img: e.img,
        ismiaosha: e.ismiaosha
      };
      wx.setStorageSync('comeBack', e.scene);
      wx.setStorageSync('options', options);
      console.log(e.scene);
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.stopPullDownRefresh();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    // 微擎登录
    we7login(e) {
      var t = this,
          a = wx.getStorageSync("userInfo");
      console.log('aaaaa');
      console.log(a);
      console.log(wx.getStorageSync("userInfo"));
      a && 0 != a.memberInfo.uid && "" != a.memberInfo ? t.setData({
        userId: a.memberInfo.uid
      }) : wx.getSetting({
        success: function (e) {
          console.log(e);
          console.log(e.authSetting["scope.userInfo"]);
          false == e.authSetting["scope.userInfo"] ? wx.showModal({
            title: "提示",
            content: "允许小程序获取您的用户信息后才可查看线索哦",
            showCancel: !1,
            success: function (e) {
              console.log(e.authSetting["scope.userInfo"]);
              e.confirm && wx.openSetting({
                success: function (e) {
                  1 == e.authSetting["scope.userInfo"] && (t.setData({
                    loginModelHidden: !1
                  }), wx.removeStorageSync("userInfo"));
                }
              });
            }
          }) : (wx.removeStorageSync("userInfo"), t.setData({
            loginModelHidden: !1
          }));
          console.log(wx.removeStorageSync("userInfo"));
          console.log(t.setData);
        }
      });
    },

    // 获取用户信息
    updateUserInfo: function (e) {
      var t = this;
      app.globalData.util.getUserInfo(function (e) {
        console.log(e); // t.login();
        // console.log(userInfo.sessionid)

        e = wx.getStorageSync("userInfo");
        let userId = wx.getStorageSync("userId"); // console.log(a)

        t.setData({
          userId: userId,
          loginModelHidden: !0
        });
      }, e.detail);
      setTimeout(function () {
        wx.navigateBack({
          detail: 1
        });
      }, 2000);
    }
  }
};
</script>
<style>
@import "./login.css";
</style>